import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-06-24
 * Time: 23:45
 */
public class Test5 {
    public static int maxArea(int[] height) {
        int n = height.length;
        int left = 0,right = n-1;
        int ret = 0;
        while(left <= right) {
            int area = Math.min(height[left],height[right]) * (right-left);
            if(height[left] < height[right]) {
                left++;
            }else {
                right--;
            }
            ret = Math.max(area,ret);
        }
        return ret;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        int ret = maxArea(num);
        System.out.println(ret);
    }
}
